package org.kabeja.dxf.entity;

import org.kabeja.dxf.DXFConstants;
import org.kabeja.dxf.helpers.Point;
import org.kabeja.math.TransformContext;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

import java.util.Map;

/**
 * @author shutao
 * @since 2022/4/25 9:11
 */
public class DXFVertex extends DXFPoint {
    private double startWidth = 0.0D;
    private double endWidth = 0.0D;
    private double bulge = 0.0D;
    private int polyFaceMeshVertex0;
    private int polyFaceMeshVertex1;
    private int polyFaceMeshVertex2;
    private int polyFaceMeshVertex3;

    public DXFVertex() {
        this.setLineType(this.getType());
    }

    public DXFVertex(Point var1) {
        super(var1);
    }

    public double getEndWidth() {
        return this.endWidth;
    }

    public void setEndWidth(double var1) {
        this.endWidth = var1;
    }

    public double getStartWidth() {
        return this.startWidth;
    }

    public void setStartWidth(double var1) {
        this.startWidth = var1;
    }

    public void toSAX(ContentHandler var1, Map var2, DXFEntity var3, TransformContext var4) throws SAXException {
    }

    @Override
    public Bounds getBounds() {
        return super.getBounds();
    }

    public double getBulge() {
        return this.bulge;
    }

    public void setBulge(double var1) {
        this.bulge = var1;
    }

    @Override
    public String getType() {
        return DXFConstants.ENTITY_TYPE_VERTEX;
    }

    public boolean isConstantWidth() {
        return this.endWidth == this.startWidth;
    }

    public boolean isCurveFitVertex() {
        return (this.flags & 1) == 1;
    }

    public boolean isTagentUsed() {
        return (this.flags & 2) == 2;
    }

    public boolean is2DSplineControlVertex() {
        return (this.flags & 16) == 16;
    }

    public boolean is2DSplineApproximationVertex() {
        return (this.flags & 8) == 8;
    }

    public boolean isPolyFaceMeshVertex() {
        return (this.flags & 64) == 64 && (this.flags & 128) == 128;
    }

    public boolean isFaceRecord() {
        return this.flags == 128;
    }

    public boolean isMeshApproximationVertex() {
        return (this.flags & 64) == 64 && (this.flags & 8) == 8;
    }

    public int getPolyFaceMeshVertex0() {
        return Math.abs(this.polyFaceMeshVertex0);
    }

    public void setPolyFaceMeshVertex0(int var1) {
        this.polyFaceMeshVertex0 = var1;
    }

    public int getPolyFaceMeshVertex1() {
        return Math.abs(this.polyFaceMeshVertex1);
    }

    public void setPolyFaceMeshVertex1(int var1) {
        this.polyFaceMeshVertex1 = var1;
    }

    public int getPolyFaceMeshVertex2() {
        return Math.abs(this.polyFaceMeshVertex2);
    }

    public void setPolyFaceMeshVertex2(int var1) {
        this.polyFaceMeshVertex2 = var1;
    }

    public int getPolyFaceMeshVertex3() {
        return Math.abs(this.polyFaceMeshVertex3);
    }

    public void setPolyFaceMeshVertex3(int var1) {
        this.polyFaceMeshVertex3 = var1;
    }

    public boolean isPolyFaceEdge0Visible() {
        return this.polyFaceMeshVertex0 > 0;
    }

    public boolean isPolyFaceEdge1Visible() {
        return this.polyFaceMeshVertex1 > 0;
    }

    public boolean isPolyFaceEdge2Visible() {
        return this.polyFaceMeshVertex2 > 0;
    }

    public boolean isPolyFaceEdge3Visible() {
        return this.polyFaceMeshVertex3 > 0;
    }
}
